package com.yulang.security;

import com.yulang.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

@Component("mobileUserDetailsServiceImpl")
public class MobileUserDetailsServiceImpl implements UserDetailsService {


    @Autowired
    private SysUserService sysUserService;

    /**
     * 手机号登录 要存储用户名 不能返回手机号，不然记住我功能会有问题
     * @param s
     * @return
     * @throws UsernameNotFoundException
     */
    @Override
    public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {
        return sysUserService.findByUsernameContainsPermission(s);
    }
}
